package com.wxm.pattern.InnerClassSingleton;

import java.io.Serializable;

/**
 * @Description 内部类单例
 * @author: wxm
 * @date: 2019/6/3 16:42
 * @version: 1.0
 */
public class LazyInnerClassSinglelon implements Serializable {

    private LazyInnerClassSinglelon() throws RuntimeException {
        if(LazyInnerClass.lazy != null){
            throw new RuntimeException("请勿创建多个实例");
        }
    }

    public static final LazyInnerClassSinglelon getInstance(){
        return LazyInnerClass.lazy;
    }

    private Object readResolve(){
        return LazyInnerClass.lazy;
    }
    private static class LazyInnerClass{
        private static final LazyInnerClassSinglelon lazy = new LazyInnerClassSinglelon();
    }
}
